| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkMemory::StringView Class Referencefinal

Class holding information about a string, with no ownership over the data. More...

## Public Member Functions
| StringView () noexcept
| StringView (const char *data) noexcept
| StringView (const char *data, unsigned long long size) noexcept
| StringView (const nkLog::StringView &logStr) noexcept
| StringView (const String &other) noexcept
| StringView (const StringView &other) noexcept
| StringView (StringView &&other) noexcept
const char * | getData () const
unsigned long long | getSize () const
bool | empty () const
char | front () const
char | back () const
const char * | begin () const
char * | begin ()
const char * | end () const
unsigned char * | end ()
BufferCast< StringView > | split (StringView separator)
StringView & | operator= (const char *data) noexcept
StringView & | operator= (const String &other) noexcept
StringView & | operator= (const StringView &other) noexcept
StringView & | operator= (StringView &&other) noexcept
char | operator[] (unsigned long long index) const
String | operator+ (char c) const
String | operator+ (const char *data) const
String | operator+ (const StringView &other) const
bool | operator== (const char *other) const
bool | operator== (const StringView &other) const
bool | operator!= (const char *other) const
bool | operator!= (const StringView &other) const
template<typename T = std::string>
| StringView (const std::string &str) noexcept
template<typename T = std::string>
| StringView (const std::string &str, unsigned long long index, unsigned long long size=0ull) noexcept
template<typename T = std::string_view>
| StringView (const std::string_view &str) noexcept
template<typename T = std::string_view>
| StringView (const std::string_view &str, unsigned long long index, unsigned long long size=0ull) noexcept
| operator std::string () const
| operator std::string_view () const
| operator nkLog::String () const
| operator nkLog::StringView () const
StringView & | operator= (const std::string &data)
StringView & | operator= (const std::string_view &data)

## Detailed Description

Class holding information about a string, with no ownership over the data.

This class will abstract a chain of characters and offer some utility to help manipulating them. The aim of this class is not to replace std::string_view within a codebase, but rather to offer a safe data exchange class from an app to the dlls, and the other way around. This class being fully exported, it doesn't suffer from the caveats a template can have in such situations.

To help in this dialog between app and dlls, the class is thought to be as transparent as possible between const char*, std::string_view and other widespread way of representing strings. Typical usage would just be to use standard structures in your app and benefit from the automatic conversions from one type to another.

Note that a view does not own the memory provided. As such, it is pretty fast as no memory shuffling is necessary. However, care must be taken when using it with temporary memory.

## Constructor & Destructor Documentation

## ◆ StringView() [1/11]

nkMemory::StringView::StringView | ( |  | ) |
| noexcept

Default constructor. Will default to a nullptr data and a size of 0.

## ◆ StringView() [2/11]

nkMemory::StringView::StringView | ( | const char * | data | ) |
| noexcept

Const char* constructor. Provided memory location will be pointed by the view. Be sure provided data is null-terminated so that its length can correctly be determined.

Parameters

  data | The pointer to the chain of characters to take over.

## ◆ StringView() [3/11]

nkMemory::StringView::StringView | ( | const char * | data,
|  | unsigned long long | size
| ) |  |
| noexcept

Guided const char* constructor. Provided memory location will be pointed and based on the size given. Prefer this constructor over the const char* constructor if you know the size required.

Parameters

  data | The pointer to the chain of characters to point to.
  size | The size of the chain provided, in number of chars.

## ◆ StringView() [4/11]

nkMemory::StringView::StringView | ( | const nkLog::StringView & | logStr | ) |
| noexcept

NilkinsLog's String view constructor.

Parameters

  logStr | String to construct the view around.

## ◆ StringView() [5/11]

nkMemory::StringView::StringView | ( | const String & | other | ) |
| noexcept

String constructor. Memory location pointed by the String will be pointed.

Parameters

  other | The string to point to.

## ◆ StringView() [6/11]

nkMemory::StringView::StringView | ( | const StringView & | other | ) |
| noexcept

Copy constructor.

Parameters

  other | The view to copy.

## ◆ StringView() [7/11]

nkMemory::StringView::StringView | ( | StringView && | other | ) |
| noexcept

Move constructor.

Parameters

  other | The view to move over.

## ◆ StringView() [8/11]

template<typename T = std::string>

nkMemory::StringView::StringView | ( | const std::string & | str | ) |
| noexcept

Standard string constructor. The string provided will be pointed by the view.

Parameters

  str | The string to point to.

## ◆ StringView() [9/11]

template<typename T = std::string>

nkMemory::StringView::StringView | ( | const std::string & | str,
|  | unsigned long long | index,
|  | unsigned long long | size = `0ull`
| ) |  |
| noexcept

Standards sub-string constructor. The string provided will be pointed by the view, at given index and size.

Parameters

  str | The string to point to.
  index | The index of the char to start the view on.
  size | The size of the view to create. If 0, will default to the whole remainder of the string starting from the index.

## ◆ StringView() [10/11]

template<typename T = std::string_view>

nkMemory::StringView::StringView | ( | const std::string_view & | str | ) |
| noexcept

Standard string view constructor. The view provided will be used to find the memory to point to.

Parameters

  str | The view to mimick.

## ◆ StringView() [11/11]

template<typename T = std::string_view>

nkMemory::StringView::StringView | ( | const std::string_view & | str,
|  | unsigned long long | index,
|  | unsigned long long | size = `0ull`
| ) |  |
| noexcept

Standards sub-string view constructor. The view provided will be used to find the memory to point to.

Parameters

  str | The view to mimick.
  index | The index of the char to start the view on.
  size | The size of the view to create. If 0, will default to the whole remainder of the string starting from the index.

## Member Function Documentation

## ◆ getData()

const char* nkMemory::StringView::getData | ( |  | ) | const

Returns
  A pointer over the memory of the view.

## ◆ getSize()

unsigned long long nkMemory::StringView::getSize | ( |  | ) | const

Returns
  The size of the view, in number of chars.

## ◆ empty()

bool nkMemory::StringView::empty | ( |  | ) | const

Returns
  Whether the view is of size 0, aka empty (true) or not (false).

## ◆ front()

char nkMemory::StringView::front | ( |  | ) | const

Returns
  The first char in the view.

## ◆ back()

char nkMemory::StringView::back | ( |  | ) | const

Returns
  The last char in the view.

## ◆ begin() [1/2]

const char* nkMemory::StringView::begin | ( |  | ) | const

Returns
  A pointer over the beginning of the memory spot.

## ◆ begin() [2/2]

char* nkMemory::StringView::begin | ( |  | ) |

Returns
  A pointer over the beginning of the memory spot.

## ◆ end() [1/2]

const char* nkMemory::StringView::end | ( |  | ) | const

Returns
  A pointer right past the end of the memory spot.

## ◆ end() [2/2]

unsigned char* nkMemory::StringView::end | ( |  | ) |

Returns
  A pointer right past the end of the memory spot.

## ◆ split()

BufferCast<StringView> nkMemory::StringView::split | ( | StringView | separator | ) |

Splits a string into multiple tokens.

Parameters

  separator | The separator pattern to use to split the string.

Returns
  The split result, one entry for each token found.

## ◆ operator=() [1/6]

StringView& nkMemory::StringView::operator= | ( | const char * | data | ) |
| noexcept

Const char* assignment operator.

Parameters

  data | The pointer over the memory to point to.

## ◆ operator=() [2/6]

StringView& nkMemory::StringView::operator= | ( | const String & | other | ) |
| noexcept

String assignment operator.

Parameters

  other | The string to point to.

## ◆ operator=() [3/6]

StringView& nkMemory::StringView::operator= | ( | const StringView & | other | ) |
| noexcept

Copy assignment operator.

Parameters

  other | The view to copy.

## ◆ operator=() [4/6]

StringView& nkMemory::StringView::operator= | ( | StringView && | other | ) |
| noexcept

Move assignment operator.

Parameters

  other | The view to move over.

## ◆ operator[]()

char nkMemory::StringView::operator[] | ( | unsigned long long | index | ) | const

Const access operator.

Parameters

  index | The index of the char to access.

## ◆ operator+() [1/3]

String nkMemory::StringView::operator+ | ( | char | c | ) | const

Char concatenation operator.

Parameters

  c | The char to concatenate.

Returns
  The result of the concatenation of calling view with the char provided.

## ◆ operator+() [2/3]

String nkMemory::StringView::operator+ | ( | const char * | data | ) | const

Char pointer concatenation operator.

Parameters

  data | The pointed data to concatenate with.

Returns
  The result of the concatenation of calling string with the data pointed.

## ◆ operator+() [3/3]

String nkMemory::StringView::operator+ | ( | const StringView & | other | ) | const

View concatenation operator.

Parameters

  other | The view to concatenate with.

Returns
  The result of the concatenation of calling view with the view provided.

## ◆ operator==() [1/2]

bool nkMemory::StringView::operator== | ( | const char * | other | ) | const

Const char* equality operator.

Parameters

  other | The const char* to check equality with.

Returns
  True if chains are the same, false otherwise.

## ◆ operator==() [2/2]

bool nkMemory::StringView::operator== | ( | const StringView & | other | ) | const

View equality operator.

Parameters

  other | The view to check equality with.

Returns
  True if chains are the same, false otherwise.

## ◆ operator!=() [1/2]

bool nkMemory::StringView::operator!= | ( | const char * | other | ) | const

Const char* inequality operator.

Parameters

  other | The const char* to check difference with.

Returns
  True if chains are different, false otherwise.

## ◆ operator!=() [2/2]

bool nkMemory::StringView::operator!= | ( | const StringView & | other | ) | const

View inequality operator.

Parameters

  other | The view to check difference with.

Returns
  True if chains are different, false otherwise.

## ◆ operator std::string()

nkMemory::StringView::operator std::string | ( |  | ) | const

Conversion operator, to std::string.

## ◆ operator std::string_view()

nkMemory::StringView::operator std::string_view | ( |  | ) | const

Conversion operator, to std::string_view.

## ◆ operator nkLog::String()

nkMemory::StringView::operator nkLog::String | ( |  | ) | const

Conversion operator, to nkLog::String.

## ◆ operator nkLog::StringView()

nkMemory::StringView::operator nkLog::StringView | ( |  | ) | const

Conversion operator, to nkLog::StringView.

## ◆ operator=() [5/6]

StringView& nkMemory::StringView::operator= | ( | const std::string & | data | ) |

Templated assignment operator.

Parameters

  data | The string to assign.

Returns
  A reference over calling view, once updated.

## ◆ operator=() [6/6]

StringView& nkMemory::StringView::operator= | ( | const std::string_view & | data | ) |

Templated assignment operator.

Parameters

  data | The string view to assign.

Returns
  A reference over calling view, once updated.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsMemory/Containers/StringView.h